package br.edu.faculdadeprojecao.modelo;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Cacheable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.validator.constraints.NotEmpty;


@Entity
public class Disciplina implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@Id @GeneratedValue @Column(unique = true)
	private Integer id;	
	
	@NotEmpty(message = "Informe a disciplina")
	@Column(unique = true)
	private String nome;	
	
	@NotNull(message = "Informe a carga horaria")
	private Integer cargaHoraria;	
	
	@OneToMany(cascade = {CascadeType.ALL}, mappedBy = "disciplina")
	private List<Competencia> competencias;	
	
	private boolean ativo = true;
	
	
	public boolean isAtivo() {
		return ativo;
	}
	public void setAtivo(boolean ativo) {
		this.ativo = ativo;
	}
	public List<Competencia> getCompetencias() {
		return competencias;
	}
	public void setCompetencias(List<Competencia> competencias) {
		this.competencias = competencias;
	}
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getNome() {
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}
	public Integer getCargaHoraria() {
		return cargaHoraria;
	}
	public void setCargaHoraria(Integer cargaHoraria) {
		this.cargaHoraria = cargaHoraria;
	}
	
	@Override
	public boolean equals(Object obj) {  
	    if (this == obj)  
	        return true;  
	    if (obj == null)  
	        return false;  
	    if (getClass() != obj.getClass())  
	        return false;  
	    Disciplina other = (Disciplina) obj;  
	    if (id == null) {  
	        if (other.id != null)  
	            return false;  
	    } else if (!id.equals(other.id))  
	        return false;  
	    return true;  
	}  

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

}
